﻿using System;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;

using Microsoft.Drawing;

namespace Spencen.Mobile.UI.Transitions
{
    public class FadeTransition : Transition
    {
        protected override void RenderFrame( Graphics compositeGraphics, Bitmap compositeBitmap, Bitmap newViewBitmap, Bitmap oldViewBitmap, Point startOffset, Brush backBrush, float adjustedValue )
        {
            var opacity = (byte) Math.Min( Math.Max( (int)( adjustedValue * 255f ), 0 ), 255 ); // Restricted to 0-255 range.

            compositeGraphics.DrawImage( oldViewBitmap, 0, 0 );
            compositeGraphics.DrawAlpha( newViewBitmap, opacity, 0, 0 );
        }
    }
}
